package com.zfx.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @description:
 * @author: zfx
 * @version: 1.0
 * @time: 2020-05-10 19:43
 * <p>
 * 修改历史：
 * 修改日期      修改人员    版本    内容
 * 2020-05-10   zfx       1.0
 */
public class DataUtil {

    private static final String pattern = "yyyy-MM-dd";

    public static Date string2Date(String sdate) {
        SimpleDateFormat sf = new SimpleDateFormat(pattern);
        try {
            return sf.parse(sdate);
        } catch (ParseException e) {
            throw new RuntimeException();
        }
    }

    public static String getCurrentTime() {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return formatter.format(currentTime);
    }

}
